import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login'
import Layout from '../views/Layout'
import Home from '../views/Layout/Home'
// import User from '../views/Layout/User'
// import Search from '../views/Search/index.vue'
// import SearchResult from '../views/Search/SearchResult.vue'
// import ArticleDetail from '../views/ArticleDetail'
// import UserEdit from '../views/Layout/User/UserEdit.vue'
// import Chat from '../views/Chat'

// 路由懒加载
const Chat = () => import(/* sebpackChunName:"Chat" */'../views/Chat')
const UserEdit = () => import(/* sebpackChunName:"UserEdit" */'../views/Layout/User/UserEdit.vue')
const ArticleDetail = () => import(/* sebpackChunName:"ArticleDetail" */'../views/ArticleDetail')
const SearchResult = () => import(/* sebpackChunName:"SearchResult" */'../views/Search/SearchResult.vue')
const Search = () => import(/* sebpackChunName:"Search" */'../views/Search/index.vue')
const User = () => import(/* sebpackChunName:"User" */'../views/Layout/User')
const _404 = () => import(/* sebpackChunName:"_404" */'../views/Miss/index.vue')

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/layout'
  },
  {
    path: '/login',
    component: Login
  },
  {
    path: '/layout',
    component: Layout,
    redirect: '/layout/home',
    children: [
      {
        path: 'home',
        component: Home,
        meta: {
          scrollY: 0
        }
      },
      {
        path: 'user',
        component: User
      }
    ]

  },
  {
    path: '/search',
    component: Search
  },
  {
    path: '/search/:keywords',
    component: SearchResult
  },
  {
    path: '/article_detail',
    component: ArticleDetail
  },
  {
    path: '/userEdit',
    component: UserEdit
  },
  {
    path: '/chat',
    component: Chat
  },
  {
    path: '*',
    component: _404
  }

]

const router = new VueRouter({
  routes
})

export default router
